home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / dbase / prg.zip / PRG.DOC < prev   
Text File  |  1987-12-14  |  5KB  |  132 lines

  1. Docs for Prg.com - dbase programmer's utility
  2. R. Trevithick, 12/02/87
  3.  
  4.  
  5. This  is  a  little  utility  program  for dBase programmers.  It
  6. provides two  basic  services,  both  geared  toward  patching up
  7. sloppy program (.prg) files.
  8.  
  9.  
  10. Structure Analysis
  11.  
  12. When invoked  with only  a filename,  it counts  up the number of
  13. flow statements which are supposed to occur in  pairs.   That is,
  14. Do While-Enddo,  Do Case-Endcase,  If-Endif and Text-Endtext.  It
  15. lists the number of occurrences of each of  these, and  flags any
  16. which are  mis-matched.   I'm told  that this  is the most common
  17. mistake made in dBase programs...
  18.  
  19.  
  20. Formatting (block indentation and case conversions)
  21.  
  22. There are three options which can be entered on the command line,
  23. following the  filename, which have to do with block indentation.
  24. Indentation simply makes programs easier to  read and understand.
  25. For example:
  26.  
  27.         If Read_File
  28.            Do While .not. Eof()
  29.               statement
  30.               statement
  31.               statement
  32.            Enddo
  33.         Endif
  34.  
  35. It's obvious  from this  that nothing  get's done if Read_File is
  36. false, and it's equally clear which  statements will  be executed
  37. inside  the  'while'  loop.    Maintaining a program without some
  38. similar kind of format can be  a nightmare,  especially when it's
  39. hundreds of lines long.
  40.  
  41. Using the  /d (display)  option after the filename will cause the
  42. file to be displayed on the screen with this sort of indentation.
  43. Note that  you have to be fairly quick with ctrl-s (pause) if you
  44. want to actually have time to look at it.
  45.  
  46. Using the /w (Write) option will cause the file you specified to
  47. actually be  re-written in  the indented style.  The revised file
  48. will be saved with the original  filename, and  the original file
  49. will be renamed to filename.old.  See the examples below.
  50.  
  51. Using the  /x option  (where x is a number from 0-9) will set the
  52. size of the indents to be  used.   It defaults  to 3.   Note that
  53. only the  first character  following the  / is  used, so a number
  54. like 15 will be read as a 1.  I sincerely hope that nobody  is in
  55. the habit  of indenting more than 9 spaces!  Also note that files
  56. displayed to the  screen  are  automatically  chopped  off  at 80
  57. characters so the wrapping doesn't hinder readability.  This will
  58. NOT happen in the file you  create with  the /w  option, however-
  59. so don't let it make you nervous.
  60.  
  61.  
  62. There are another three options which allow case conversions to be made.  
  63. Comments beginning with '*', and anything between a 'TEXT' and an 
  64. 'ENDTEXT' will be left unchanged.
  65.  
  66. Using the /u option will convert all characters to Upper case.
  67.  
  68. The /l option will convert all characters to Lower case, with the
  69. exception of the first character of words.  Hence, 'SET' would be 
  70. changed to 'Set'.
  71.  
  72. The /f option will Force all characters to lower case, including the 
  73. first characters of words.  Hence, 'SET' would become 'set'.
  74.  
  75.  
  76. Examples
  77.  
  78. Let's say  we have  a file  called Test.Prg which we want to work
  79. with.  Suggestion: copy one of your existing  files to  a special
  80. directory, and use it for experimenting.
  81.  
  82. We could enter the following commands:
  83.  
  84. prg test
  85.  
  86.    This  would  simply  display  a  listing  of  the  number of
  87.    occurrences of statements such as 'Do while' and  'Enddo' in
  88.    your file.   Obviously, you have a problem if there are more
  89.    Do While's than Enddo's or vice-versa.
  90.  
  91. prg test /d
  92.  
  93.    This would cause the file to be listed to the  screen in the
  94.    indented format described above.
  95.  
  96. prg test /w
  97.  
  98.    This  would  re-write  the  'Test.Prg'  file in the indented
  99.    format, and save an unmodified version of the  original file
  100.    under the name 'Test.Old'.
  101.  
  102. prg test /d /5
  103.  
  104.    This would display the file with blocks indented by 5 spaces
  105.    instead of 3.
  106.  
  107. prg test /w /5 /l
  108.  
  109.    This would  format  the  file  (see  /w  above)  with blocks
  110.    indented by 5 spaces instead of the default 3.  The revised file 
  111.    would have all characters converted to lower case unless they were 
  112.    the first character of a word or withing a comment or a text block.
  113.  
  114. You can,  of course,  use all  options in combination if you want
  115. to.
  116.  
  117. prg test /d /w /5 /l
  118.  
  119.    This would both display AND re-write  the file  with 5 space
  120.    indenting and lower case conversion.
  121.  
  122.  
  123. *NOTE that the command line is parsed from left to right, so if you 
  124.       enter conflicting options (such as /l for lower case and /u for 
  125.       upper case) the rightmost one will be honored.
  126.  
  127.  
  128. ------------Changes as of 12/02/87 revision------------
  129. Added case conversion routines (/l /f /u)
  130.  
  131.  
  132.